/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#pragma once

/// Omen Headers
#include "OmenConfig.h"

#include <IOmenModel.h>
#include <IOmenMesh.h>

/// STL Headers
#include <vector>

namespace Omen
{
    class Model : public Omen::IModel
    {
          #define GUID_OMEN_MODEL "82641FEC-44FC-4C83-9AED-5E91DBB8E7AB"

    public:
        OMEN_API virtual Omen_GUID classId() const { return OMEN_UUID(GUID_OMEN_MODEL); }    /// <summary>Defines the class ID</summary>

        OMEN_API Model();
        OMEN_API Model( const Model& other );
        OMEN_API virtual ~Model();

        /// Parenting Scene
        OMEN_API virtual void setScene( Omen::IScene* pScene );
        OMEN_API virtual Omen::IScene* scene() const;

        /// Meshes
        OMEN_API virtual unsigned long meshCount() const;
        OMEN_API virtual void addMesh( IMesh* pMesh );
        OMEN_API virtual void getMeshes( IMesh** pMeshList, unsigned long& maxSize );
        OMEN_API virtual Omen::IMesh* getMesh( unsigned long index );
    
        OMEN_API virtual void setTransformation( const Omen::Matrix4x4& matrix );
        OMEN_API virtual Omen::Matrix4x4 const& transformation() const;

        /// Collision detection
        OMEN_API virtual bool testCollision( ICollidable** pListObjects, unsigned long maxNum );
        OMEN_API virtual void updateBoundingVolume();           /// <summary>Updates the bounding volumes, aabb and sphere of this model</summary>

        OMEN_API virtual const Omen::AABB& boundingBox() const;               /// <summary>Returns the axis aligned bounding box of the model</summary>
        OMEN_API virtual const Omen::Sphere& boundingSphere() const;          /// <summary>Returns the bounding sphere of the model</summary>

        OMEN_API virtual const Omen::Vector3d& center();                /// <summary>Returns the center point of this model in global 3d coordinate space</summary>

        OMEN_API virtual void setScale( const Omen::Vector3d& scale );
        OMEN_API virtual Omen::Vector3d scale() const;

        /// IObject property functions
        OMEN_API virtual void setProperty( const std::wstring& propertyName, const std::wstring& propertyValue );

        /// Omen Model needs to be updated on next frame
        OMEN_API virtual void setUpdateNeeded( bool bNeeded );
    protected:
    
    private:
        //#pragma warning(disable:4251) // Disable warning about private member variable needs to have dll-interface to be used by clients of class 'this'
        Omen::Matrix4x4         m_transformation;
        std::vector< IMesh* >   m_meshes;
        IBoundingVolume*        m_boundingVolume;
        Omen::Sphere            m_boundingSphere;
        Omen::AABB              m_boundingBox;
        Omen::Vector3d          m_center;
        Omen::IScene*           m_pScene;
        Omen::Vector3d          m_scale;
        bool                    m_bUpdateNeeded;
        //#pragma warning(default:4251) // Set the default state of the warning
    };
}

/// EOF